home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / mus / play / DES_Tracker2_00.lha / DTL / include / libraries / dtlib.h next >
C/C++ Source or Header  |  1993-12-17  |  16KB  |  352 lines

  1. #ifndef    DTLIB_H
  2. #define    DTLIB_H
  3.  
  4. /*==========================================================*/
  5. /* DTLib.H -- External declarations for DES-Tracker Library */
  6. /*                                                            */
  7. /*                Release: 2.00                                */
  8. /*                Version: 3.0                                */
  9. /*                                                            */
  10. /* Designed and written by Darren Schebek                    */
  11. /* Copyright (c)1992,1993 by Darren Schebek                    */
  12. /*                                                            */
  13. /* rel 1.1         Begun: Sun, Aug 31, 1991                    */
  14. /* rel 1.2  Last updated: Fri, Sep  4, 1992                    */
  15. /* rel 1.5  Last updated: Fri, Jan  1, 1993                    */
  16. /* rel 1.6  Last updated: Thu, Jan 14, 1993                    */
  17. /* rel 1.61 Last updated: Sun, Jan 27, 1993                    */
  18. /* rel 1.62 Last updated: Sat, Jan  6, 1993                    */
  19. /* rel 1.63 Last updated: Wed, Jan 10, 1993                    */
  20. /* rel 1.64 Last updated: Thu, May 22, 1993                    */
  21. /* rel 2.00 Last updated: Sat, Dec 18, 1993                    */
  22. /*==========================================================*/
  23.  
  24.  
  25. /*===================================*/
  26. /* Library Data Structures follow... */
  27. /*===================================*/
  28.  
  29.  
  30. /*------------------------------------------------------------------------------*/
  31. /* CHANNELSTATUS structure follows. DTL_Base contains four instances of this    */
  32. /* structure, called dtl_Channel0, dtl_Channel1, etc.  This structure contains    */
  33. /* information concerning an individual sound channel (0 to 3).  The info        */
  34. /* contained here is only valid when a module is loaded and a play sequence        */
  35. /* is active...                                                                    */
  36.  
  37. struct CHANNELSTATUS
  38.     {
  39.     UBYTE    cs_Note;         /* The # of last note played (0..11).                    */
  40.     UBYTE    cs_Octave;         /* The octave # of the last note played (0..2).        */
  41.     UBYTE    cs_NoteNum;         /* cs_Note & cs_Octave combined (Note+(12*Octave)).    */
  42.     UBYTE    cs_Volume;         /* Current volume of this channel (0..64).                */
  43.     UBYTE    cs_RealVolume;     /* Cur. channel volume with Global Volume applied.        */
  44.     UBYTE    cs_Pad;             /* Reserved.  Always zero.                                */
  45.     UWORD    cs_Period;         /* Current period of this channel.                        */
  46.     APTR    cs_Instrument;     /* Pointer to INSTSTATUS struct used by this channel.    */
  47.     ULONG    cs_SampleOffset; /* Offset from inst. start if SampleOffset was used.    */
  48.     };
  49.  
  50.  
  51. /*------------------------------------------------------------------------------*/
  52. /* MODULESTATUS structure follows.  DTL_Base contains an instance of this        */
  53. /* structure.  It contains information specific to the currently loaded module.    */
  54. /* This information is valid only when a module is loaded...                    */
  55.  
  56. struct MODULESTATUS
  57.     {
  58.     APTR    ms_Name;            /* Pointer to title of loaded song module        */
  59.     ULONG    ms_Length;            /* Length of entire module in memory.            */
  60.     APTR    ms_PlaySeqArray;    /* Ptr to play seq. array (dbl-long elements).    */
  61.     APTR    ms_PatternData;        /* Ptr to the module's pattern data.            */
  62.     APTR    ms_InstInfoBlocks;  /* Ptr to 31 internal instrument blocks (30 bytes each). */
  63.     UBYTE    ms_Format;            /* Either MF_SOUNDTRACKER or MF_NOISETRACKER.    */
  64.     UBYTE    ms_Version;            /* Module format version.                        */
  65.     UBYTE    ms_Revision;        /* Module format revision.                        */
  66.     UBYTE    ms_Reserved;        /* Always 0.                                    */
  67.     APTR    ms_Instruments;        /* Ptr to 1st INSTSTATUS struct in linked list.    */
  68.     UWORD    ms_NumPatterns;        /* Number of unique patterns defined in module.    */
  69.     UWORD    ms_NumPositions;    /* Numberof 4-pattern groups to play in module.    */
  70.     APTR    ms_Pathname;        /* Ptr to pathspec from which module was loaded.*/
  71.     APTR    ms_Filename;        /* Ptr to current filename of this module.        */
  72.     };
  73.  
  74.  
  75. /* Values for ms_Format... */
  76.  
  77. enum MODFORMATS
  78.     {
  79.     MF_SOUNDTRACKER = 1,
  80.     MF_NOISETRACKER,
  81.     MF_DESTRACKER
  82.     };
  83.  
  84.  
  85. /*----------------------------------------------------------------------------------*/
  86. /* Instrument Status structure follows.  The ms_Instruments field points to the        */
  87. /* first of a linked list of these structures.  There is one instrument structure    */
  88. /* in the linked list for each instrument used by the module...                        */
  89.  
  90. struct INSTSTATUS
  91.     {
  92.     APTR    is_Next;        /* Pointer to next instrument in linked list.    */
  93.     APTR    is_Name;        /* Pointer to name of this instrument.            */
  94.     APTR    is_Address;        /* Pointer to instrument in memory.                */
  95.     ULONG    is_Length;        /* Length of this instrument in bytes.            */
  96.     ULONG    is_Repeat;        /* Repeat loop offset in bytes.                    */
  97.     ULONG    is_RepeatLen;    /* Length of repeat loop in bytes.                */
  98.     UBYTE    is_Number;        /* The number of this instrument within module.    */
  99.     BYTE    is_FineTune;    /* Fine tune amount for instrument (-8..7).        */
  100.     UBYTE    is_Volume;        /* The default volume of this instrument.        */
  101.     UBYTE    is_Reserved;    /* Reserved field. Should always be 0.            */
  102.     };
  103.  
  104. /*------------------------------------------------------------------------------*/
  105. /* PATHENTRY structure, used for storing search paths for LoadModule.            */
  106. /* The path string itself appears immediately after the pe_Length field, and    */
  107. /* is always NULL-terminated.  Also, the value in pe_Length includes the        */
  108. /* terminating NULL.                                                                                */
  109.  
  110. struct PATHENTRY
  111.     {
  112.     APTR    pe_Next;        /* Ptr to next PATHENTRY struct in linked list.    */
  113.     UWORD    pe_Length;        /* Length of the NULL-terminated path string.    */
  114.     };
  115.  
  116. /*----------------------------------------------------------------------------*/
  117. /* timescaninfo structure.  This structure is passed to the CalcElapsedTime() */
  118. /* function.  See description of this function in the DTLibFuncs.DOC file     */
  119. /* for more details.                                                          */
  120.  
  121. struct timescaninfo
  122.     {
  123.     UBYTE    tsi_StartPos;        /* Start position for the time scan.        */
  124.     UBYTE    tsi_StartNote;        /* Start note offset for the time scan.        */
  125.     UBYTE    tsi_EndPos;            /* End position for the time scan.            */
  126.     UBYTE    tsi_EndNote;        /* End note offset for the time scan.        */
  127.     UBYTE    tsi_Flags;            /* Flags used for the time scan (see below).*/
  128.     UBYTE    tsi_DefaultTempo;    /* Initial default tempo for scan.            */
  129.     UBYTE    tsi_FineTempo;        /* Fine Tempo used for the time scan.        */
  130.     UBYTE    tsi_Pad;            /* Pad byte. Must always be 0.                */
  131.  
  132. /*  The CalcElapsedTime() function fills these next fields out for you...    */
  133.  
  134.     ULONG    tsi_FirstIterTime;    /* Time for first iteration of play seq.    */
  135.     ULONG    tsi_ConsecIterTime;    /* Time for consecutive iterations.            */
  136.     };
  137.  
  138. /*    Bit definitions for the tsi_Flags field...    */
  139.  
  140. enum TSI_FLAGS
  141.     {
  142.     TSIB_MULTIPLEITERS,    /* Set to calc tsi_ConsecIterTime.                */
  143.     TSIB_TEMPOINTERP,    /* Tempo interpretation for scan (0=BPM enabled)*/
  144.     TSIB_TIMINGMODE        /* Timing mode (0=60Hz, 1=50Hz).                */
  145.     };
  146.  
  147. /* Bit mask definitions for the tsi_Flags field...    */
  148.  
  149. #define    TSIF_MULTIPLEITERS    (1 << TSIB_MULTIPLEITERS)
  150. #define    TSIF_TEMPOINTERP    (1 << TSIB_TEMPOINTERP)
  151. #define    TSIF_TIMINGMODE        (1 << TSIB_TIMINGMODE)
  152.  
  153.  
  154. /*------------------------------------------------------------------------------*/
  155. /* DTL_Base structure, returned by OpenLibrary.  This is the structure that        */
  156. /* you get a pointer to when you open this library. It contains lots of            */
  157. /* information about each sound channel, the currenlty loaded module (if one    */
  158. /* is loaded), and the play sequence parameters.                                */
  159. /*                                                                                */
  160. /* NOTE: EVERY ONE of these variables are READ ONLY!  NEVER attempt to write    */
  161. /*       to ANY of them. (Besides, you cannot affect the library by changing    */
  162. /*       the parameters in this structure, you will only be destroying valuable    */
  163. /*       status information for both you and anyone else using the library).    */
  164.  
  165. struct    DTL_Base
  166.     {
  167.     struct    Library    dtl_lib;    /* DTBase (public data).                    */
  168.     APTR    dtl_SysLib;            /* A pointer to ExecBase for you to use.    */
  169.     APTR    dtl_DosLib;            /* A pointer to DosBase for you to use.        */
  170.     APTR    dtl_RexxSysLib;        /* A pointer to RexxSysBase for me to use.    */
  171.     APTR    dtl_SegList;        /* Off limits. Ne touche pas!                */
  172.     APTR    dtl_System;            /* Off limits as well.                        */
  173.     UBYTE    dtl_SysFlags;        /* Once again... off limits.                */
  174.     UBYTE    dtl_WhichTimer;        /* Holds CIA timer that DES-Tracker is using.*/
  175.  
  176. /* The following variables are always valid, whether a module is loaded or not... */
  177.  
  178.     APTR    dtl_ModPathList;    /* Pointer to 1st PATHENTRY in linked list.        */
  179.     UWORD    dtl_Flags;            /* DTL_Base flags (see below).                    */
  180.     UWORD   dtl_Flags2;            /* Extra Flags for DES-Tracker r1.2.            */ 
  181.     UBYTE    dtl_GlobalVolume;    /* Global volume for all channels (0..63).        */
  182.     BYTE    dtl_GlobalTempo;    /* Global tempo for all modules (-16..15).        */
  183.     BYTE    dtl_FineTempo;        /* Fine tempo adjustment (-128..127).            */
  184.     UBYTE    dtl_DefaultTempo;    /* Default tempo (0..255) for start of play seq.*/
  185.     UBYTE    dtl_VolFadeRate;    /* Speed at which volume fades transpire.        */
  186.     UBYTE    dtl_Iterations;        /* Number of iterations for play sequence.        */
  187.     UBYTE    dtl_TimingMode;        /* Holds 0 if NTSC timing is used, 1 if PAL.    */
  188.     UBYTE    dtl_SaveFormat;        /* Holds save file format for SaveModule func.    */
  189.     UBYTE    dtl_PlayStatus;        /* Holds play-status value. See below.            */
  190.  
  191. /* The following variables are valid only when a module is loaded... */
  192.  
  193.     UBYTE    dtl_DefIterations;    /* Default # of iterations for play sequence.    */
  194.     UBYTE    dtl_IterationsToGo;    /* Number of iterations left including current.    */
  195.     UBYTE    dtl_CurPosition;    /* Current position in play sequence.            */
  196.     UBYTE    dtl_CurNoteIndex;    /* Current note index into current position.    */
  197.     UBYTE    dtl_StartPosition;    /* Play sequence start position.                */
  198.     UBYTE    dtl_StartNoteIndex;    /* Play sequence start note index into pos.        */
  199.     UBYTE    dtl_EndPosition;    /* Play sequence end position.                    */
  200.     UBYTE    dtl_EndNoteIndex;    /* Play sequence end note index into pos.        */
  201.     UBYTE    dtl_CurrentTempo;    /* Current tempo (including global tempo).        */
  202.  
  203.     struct    CHANNELSTATUS dtl_Channel0;    /* Status info for channel 0. */
  204.     struct    CHANNELSTATUS dtl_Channel1;    /* Status info for channel 1. */
  205.     struct    CHANNELSTATUS dtl_Channel2;    /* Status info for channel 2. */
  206.     struct    CHANNELSTATUS dtl_Channel3;    /* Status info for channel 3. */
  207.  
  208.     struct    MODULESTATUS dtl_ModuleStatus;    /* Status info for currently loaded module. */
  209.  
  210. /* The following variables are valid only when a song is playing... */
  211.  
  212.     UBYTE    dtl_ElapsedHours;    /* # of hours that song has been playing for.    */
  213.     UBYTE    dtl_ElapsedMinutes;    /* # of minutes elapsed while playing.            */
  214.     UBYTE    dtl_ElapsedSeconds;    /* # of seconds elapsed.                        */
  215.     UBYTE    dtl_ElapsedJiffies;    /* # of 60ths of a second elapsed.                */
  216.  
  217.     ULONG    dtl_ElapsedTime;    /* Total current elapsed time in 60ths of a sec. */
  218.  
  219.     ULONG    dtl_CurrentHertz;    /* Current interrupt frequency (Fixed-point Int).*/
  220.     };
  221.  
  222.  
  223. /* Bit definitions for dtl_Flags field... */
  224.  
  225. enum DTLFLAGS
  226.     {
  227.     DF_CH0STATUS,        /* Set to 1 if channel 0 is enabled, 0 if disabled.    */
  228.     DF_CH1STATUS,        /* Same as above, but for channel 1.                */
  229.     DF_CH2STATUS,        /* Same for channel 2.                                */
  230.     DF_CH3STATUS,        /* Same for channel 3.                                */
  231.     DF_FILTERSTATUS,    /* Set to 1 when filter is on, 0 when off.            */
  232.     DF_MODULELOADED,    /* Set to 1 when a module is currently loaded.        */
  233.     DF_PLAYSEQDONE,        /* Set to 1 when a play sequence ends.                */
  234.     DF_PLAYING,            /* Set to 1 whenever a play sequence is active.        */
  235.     DF_CH0NOTEHIT,        /* Toggles between 1 and 0 when a note is played.    */
  236.     DF_CH1NOTEHIT,        /* Same as above,  but for channel 1.                */
  237.     DF_CH2NOTEHIT,        /* Same for channel 2.                                */
  238.     DF_CH3NOTEHIT,        /* Same for channel 3.                                */
  239.     DF_AUTOTIMING,        /* Set to 1 if auto timing detection is enabled.    */
  240.     DF_LOOPINTENT,        /* Set to 1 if this song is meant to loop.            */
  241.     DF_MODULECHANGED,    /* Toggles each time a change is made to a module.    */
  242.     DF_LIBLOCKED        /* Set when someone has OWNed the library.            */
  243.     };
  244.  
  245. /* Bit definitions for dtl_Flags2 field... */
  246.  
  247. #define DF_HASPSC0            14    /* 0=File has no PSC0 construct, 1=Has PSC0    const.    */
  248. #define    DF_TEMPOINT            15    /* 0=Normal/BPM tempos, 1=Normal tempos only.        */
  249.  
  250. /* Bit Mask values for dtl_Flags... */
  251.  
  252. #define    DFM_CH0STATUS        (1 << DF_CH0STATUS)
  253. #define    DFM_CH1STATUS        (1 << DF_CH1STATUS)
  254. #define    DFM_CH2STATUS        (1 << DF_CH2STATUS)
  255. #define    DFM_CH3STATUS        (1 << DF_CH3STATUS)
  256. #define    DFM_FILTERSTATUS    (1 << DF_FILTERSTATUS)
  257. #define    DFM_MODULELOADED    (1 << DF_MODULELOADED)
  258. #define    DFM_PLAYSEQDONE        (1 << DF_PLAYSEQDONE)
  259. #define    DFM_PLAYING            (1 << DF_PLAYING)
  260. #define    DFM_CH0NOTEHIT        (1 << DF_CH0NOTEHIT)
  261. #define    DFM_CH1NOTEHIT        (1 << DF_CH1NOTEHIT)
  262. #define    DFM_CH2NOTEHIT        (1 << DF_CH2NOTEHIT)
  263. #define    DFM_CH3NOTEHIT        (1 << DF_CH3NOTEHIT)
  264. #define    DFM_AUTOTIMING        (1 << DF_AUTOTIMING)
  265. #define    DFM_LOOPINTENT        (1 << DF_LOOPINTENT)
  266. #define    DFM_MODULECHANGED    (1 << DF_MODULECHANGE)
  267. #define    DFM_LIBLOCKED        (1 << DF_LIBLOCKED)
  268.  
  269. /* Bit Mask values for dtl_Flags2... */
  270.  
  271. #define DFM_HASPSC0            (1 << DFM_HASPSC0)
  272. #define    DFM_TEMPOINT        (1 << DFM_TEMPOINT)
  273.  
  274. /* Values for dtl_PlayStatus... */
  275.  
  276. enum STATUSVALUES
  277.     {
  278.     PS_NOMODULE,    /* No module is loaded.                            */
  279.     PS_IDLE,        /* Module loaded but hasn't started playing yet.*/
  280.     PS_PLAYING,        /* Module is currently playing.                    */
  281.     PS_PAUSED,        /* Module is paused.                            */
  282.     PS_STOPPED,        /* Module was playing but has been stopped.        */
  283.     PS_PLAYSEQDONE    /* Module has finished playing.                    */
  284.     };
  285.  
  286. /*------------------------------------------------------------------*/
  287. /* Signal event bit definitions for AddStatusSignal() function...    */
  288.  
  289. enum SIGEVENTBITS
  290.     {
  291.     SEB_START,            /* Signal when play sequence starts.            */
  292.     SEB_FINISH,            /* Signal when play sequence is completed.        */
  293.     SEB_PAUSE,            /* Signal whenever play is paused.                */
  294.     SEB_CONTINE,        /* Signal whenever play is un-paused.            */
  295.     SEB_STOP,            /* Signal when play sequence is stopped.        */
  296.     SEB_ITERATION,        /* Signal upon completion of an iteration.        */
  297.     SEB_PATTERN,        /* Signal when a pattern completes.                */
  298.     SEB_VOLFADE,        /* Signal upon completion of a volume fade.        */
  299.     SEB_MODLOADED,        /* Signal when a new module is loaded.            */
  300.     SEB_MODUNLOADED,    /* Signal when current module is unloaded.        */
  301.     SEB_LIBOWNED,        /* Signal when library becomes locked.            */
  302.     SEB_LIBDISOWNED,    /* Signal when library no longer locked.        */
  303.     SEB_MINUTE,            /* Signal on each minute of elapsed play-time.    */
  304.     SEB_SECOND            /* Signal on each second of elapsed play-time.    */
  305.     };
  306.  
  307. /* Signal event mask definitions...    */
  308.  
  309. #define    SEF_START            (1 << SEB_START)
  310. #define    SEF_FINISH            (1 << SEB_FINISH)
  311. #define    SEF_PAUSE            (1 << SEB_PAUSE)
  312. #define    SEF_CONTINUE        (1 << SEB_CONTINE)
  313. #define    SEF_STOP            (1 << SEB_STOP)
  314. #define    SEF_ITERATION        (1 << SEB_ITERATION)
  315. #define    SEF_PATTERN            (1 << SEB_PATTERN)
  316. #define    SEF_VOLFADE            (1 << SEB_VOLFADE)
  317. #define    SEF_MODLOADED        (1 << SEB_MODLOADED)
  318. #define    SEF_MODUNLOADED        (1 << SEB_MODUNLOADED)
  319. #define    SEF_LIBOWNED        (1 << SEB_LIBOWNED)
  320. #define    SEF_LIBDISOWNED        (1 << SEB_LIBDISOWNED)
  321. #define SEF_MINUTE            (1 << SEB_MINUTE)
  322. #define SEF_SECOND            (1 << SEB_SECOND)
  323.  
  324. /*--------------------------------------------------------------*/
  325. /* Error codes returned by the library routines...                */
  326.  
  327. #define    DE_SUCCESS        0
  328.  
  329. #define    DE_LIB_ALREADY_OWNED    -1    /* Someone else has owned the library.                */
  330. #define    DE_NO_MODULE_LOADED        -2    /* Command required a module to be in memory.        */
  331. #define    DE_NO_PLAY_SEQ_ACTIVE    -3    /* Command required a play sequence to be active.    */
  332. #define    DE_IVALUE_OUT_OF_RANGE    -4    /* Input value was out of range.                    */
  333. #define    DE_VALUE_WAS_TRIMMED    -5    /* Input value was trimmed to legal range.            */
  334. #define    DE_FILE_LOAD_ERROR        -6    /* An error occurred while attempting to read file.    */
  335. #define    DE_INSUFFICIENT_MEMORY    -7    /* Insufficient free memory for operation.            */
  336. #define    DE_ILLEGAL_PATHNAME        -8    /* Pathname is not in proper pathname format.        */
  337. #define    DE_UNKNOWN_FORMAT        -9    /* Specified song file is not a recognized format.    */
  338. #define    DE_FILE_SAVE_ERROR        -10    /* An error occurred while attempting to write file.*/
  339. #define    DE_NO_INSTRUMENT        -11    /* An instrument name was required (ARexx only).    */
  340. #define    DE_FILE_NOT_FOUND        -12    /* Specified file couldn't be found.                */
  341. #define    DE_MISSING_INST            -13    /* Instrument(s) missing from song being loaded.    */
  342. #define    DE_PLAY_SEQ_ACTIVE        -14    /* Returned by ContinuePlaySeq() if already playing.*/
  343. #define DE_TOO_MANY_PATTERNS    -15 /* Can only happen when saving in ST2.6 format.        */
  344. #define DE_CH_ENABLE_FAILED        -16    /* User-specified audio channel could not be enabled.*/
  345.  
  346. /*--------------------------------------------------------------*/
  347. /* A define for you to use (that you should use)...                */
  348.  
  349. #define    DTLIBNAME    "destracker.library"
  350.  
  351. #endif
  352.